package com.spring.demo.corp.handler;

import com.spring.demo.corp.PayOrderForm;
import com.spring.demo.corp.PayOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class PayOrderChainProcessor {

    @Autowired
    private List<PayOrderService> payOrderServices;

    public void handlePayOrder(PayOrderForm payOrderForm) {
        for (PayOrderService payOrderService : payOrderServices) {
            boolean payOrder = payOrderService.payOrder(payOrderForm);
            if (!payOrder) break;
        }
    }

}
